package framelib.utils;

import java.lang.reflect.InvocationTargetException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Title:DateUtil
 * Description:
 * @Create_by:Vince Yu
 * @Create_date:2012-5-9
 * @Last_Edit_By:
 * @Edit_Description
 * @version:ShareWithUs 1.0
 * 
 */
public class DateUtil {
	
	/**
	 * Title:getSystemTime
	 * Description:获取系统时间
	 * @Create_by:Vince Yu
	 * @Create_date:2012-5-9
	 * @Last_Edit_By:
	 * @Edit_Description
	 * @Create_Version:ShareWithUs 1.0
	 */
	public static Timestamp getSystemTime() throws IllegalAccessException, InvocationTargetException {
		return new Timestamp(System.currentTimeMillis());
	}
	/**
	 * Title:getSystemTime
	 * Description:根据类型获取系统时间
	 * @param type 时间类型 date：日期，second：时间
	 * @Create_by:Vince Yu
	 * @Create_date:2012-5-9
	 * @Last_Edit_By:
	 * @Edit_Description
	 * @Create_Version:ShareWithUs 1.0
	 */
	public static String getSystemTime(String type) throws IllegalAccessException, InvocationTargetException {
		String formcat = "";
		if(type.equalsIgnoreCase("date")){
			formcat = "yyyy-MM-dd";
		}else if(type.equalsIgnoreCase("second")){
			formcat = "yyyy-MM-dd hh:mm:ss";
		}
		SimpleDateFormat   bartDateFormat   =new   SimpleDateFormat(formcat);
		Date   date   =   new   Date();
		return bartDateFormat.format(date).toString();
	}
	
	
	public static String getSystemTime4Name() throws IllegalAccessException, InvocationTargetException {
		String formcat = "";
		formcat = "yyyy-MM-dd-hh-mm-ss";
		SimpleDateFormat   bartDateFormat   =new   SimpleDateFormat(formcat);
		Date   date   =   new   Date();
		return bartDateFormat.format(date).toString();
	}
	
}
